home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0047_VGA ClrScr #3.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  102 lines

  1. {
  2. I also wanted to put a picture bigger than the screen to scroll over
  3. For the intro.  --  ANIVGA  --
  4. }
  5.  
  6. Program ScrollExample;
  7. {Demonstrates how to use the VGA's hardware scroll to do some nice opening}
  8. {sequence: the Program loads 3 Graphic pages With data and then scrolls   }
  9. {them by. note that this erases the contents of the background page and   }
  10. {thus shouldn't be used While animating sprites in parallel!}
  11.  
  12. Uses
  13.   ANIVGA, Crt;
  14.  
  15. Procedure IntroScroll(n,wait:Word);
  16. { in: n    = # rows to scroll up using hardware zoom}
  17. {     wait = time (in ms) to wait after each row    }
  18. {rem: Scrolling *always* starts at page 0 (=$A000:0000)   }
  19. {     Thus, issuing "Screen(1-page)" afterwards is a must!}
  20. {     if you put the routine into ANIVGA.PAS, you should delete all the}
  21. {     Constants following this line}
  22. Const
  23.   StartIndex=0;
  24.   endIndex=StartIndex+3;
  25.   {offsetadressen der Grafikseiten (in Segment $A000):}
  26.   offset_Adr:Array[StartIndex..endIndex] of Word=($0000,$3E80,$7D00,$BB80);
  27.   CrtAddress=$3D4; {if monochrome: $3B4}
  28.   StatusReg =$3DA; {if monochrome: $3BA}
  29. begin
  30.   Screen(0);                  {position at $A000:0000}
  31.   Asm
  32.     xor SI,SI                {use page address 0 }
  33.     and SI,3
  34.     SHL SI,1
  35.     ADD SI,ofFSET offset_Adr-StartIndex*2 {call this "defensive Programming"..}
  36.     LODSW
  37.     MOV BX,AX
  38.     MOV CX,n
  39.     MOV SI,wait
  40.   @oneline:
  41.     ADD BX,LinESIZE
  42.     CLI                      {no inTs please!}
  43.     MOV DX,StatusReg
  44.     @WaitnotHSyncLoop:
  45.       in   al,dx
  46.       and  al,1
  47.       jz  @WaitnotHSyncLoop
  48.     @WaitHSyncLoop:
  49.       in   al,dx
  50.       and  al,1
  51.       jz   @WaitHSyncLoop
  52.     MOV DX,CrtAddress        {Crt-controller}
  53.     MOV AL,$0D               {LB-startaddress-register}
  54.     OUT DX,AL
  55.     inC DX
  56.  
  57.     MOV AL,BL
  58.     OUT DX,AL                {set new LB of starting address}
  59.     DEC DX
  60.     MOV AL,$0C
  61.     OUT DX,AL
  62.     inC DX
  63.     MOV AL,BH                {dto., HB}
  64.     OUT DX,AL
  65.     STI
  66.  
  67.     PUSH BX
  68.     PUSH CX
  69.     PUSH SI
  70.     PUSH SI
  71.     CALL Crt.Delay
  72.     POP SI
  73.     POP CX
  74.     POP BX
  75.     LOOP @oneline
  76.   end;
  77. end;
  78.  
  79. begin
  80.  InitGraph; {Program VGA into Graphic mode, clear all pages}
  81.  
  82.  {--- Start of Intro ---}
  83.  Screen(0); {or SCROLLPAGE, just an aesthetic question...}
  84.  {Load 3 pages With pics, or draw them:}
  85.  LoadPage('1st.PIC',0);
  86.  LoadPage('2nd.PIC',1);
  87.  LoadPage('3rd.PIC',BackgndPage);
  88.  IntroScroll(3*200,20); {scroll up 3 pages, wait 20ms}
  89.  Delay(3000); {wait a few seconds}
  90.  Screen(1-page); {restore correct mode}
  91.  {--- end of Intro ---}
  92.  
  93.  {now do your animations as usual}
  94.  {...}
  95.  CloseRoutines;
  96. end.
  97.  
  98. {
  99. if you adjust LoadPage() to allow loading into Graphic page 3 (=SCROLLPAGE),
  100. too, you may easily do a 4 screen hardware scroll!
  101. }
  102.